#include <iostream>
using namespace std;
#include "BSTree.h"

void TestBSTree4()
{
    key_value::BSTree<string, string> dict;
    dict.Insert("sort", "排序");
    dict.Insert("left", "左边");
    dict.Insert("right", "右边");
    dict.Insert("string", "字符串");
    dict.Insert("insert", "插入");
    dict.Insert("erase", "删除");

    string str;
    while (cin>>str)
    {
        auto ret = dict.Find(str);
        if (ret)
        {
            cout << ":" << ret->_value << endl;
        }
        else
        {
            cout << "无此单词" << endl;
        }
    }
}

void TestBSTree5()
{
    string arr[] = { "西瓜", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜", "苹果", "香蕉", "苹果", "香蕉", "梨"};

    key_value::BSTree<string, int> countTree;
    for (auto str : arr)
    {
        //key_value::BSTreeNode<string, int>* ret = countTree.Find(str);
        auto ret = countTree.Find(str);
        if (ret == nullptr)
        {
            countTree.Insert(str, 1);
        }
        else
        {
            ret->_value++;
        }
    }

    countTree.InOrder();
}

int main() {
    int a[] = { 8, 3, 1, 10, 6, 4, 7, 14, 13 };
    BSTree<int> t1;
    for (auto e : a)
    {
        t1.Insert(e);
    }
    t1.InOrder();
    t1.EraseR(8);
    t1.InOrder();
//    TestBSTree4();
//    TestBSTree5();


    return 0;

}
